
using System;
using System.Linq;
using Csla;
using Csla.Data;
using HousingInfo.DataLinQ;

namespace HousingInfo.Library
{ 
	public partial class NewsSaveBOList : Csla.BusinessListBase<NewsSaveBOList, NewsSaveBO>
	{

		#region Authorization Rules

		protected static void AddObjectAuthorizationRules()
		{
			//TODO: Define object-level authorization rules of NewsSaveBOList
			//AuthorizationRules.AllowCreate(typeof(NewsSaveBOList), "NewsSaveBOListCreateGroup"));
			//AuthorizationRules.AllowEdit(typeof(NewsSaveBOList), "NewsSaveBOListEditGroup"));
			//AuthorizationRules.AllowDelete(typeof(NewsSaveBOList), "NewsSaveBOListDeleteGroup"));
		}
		#endregion //Authorization Rules

        #region Ham kiem tra tin da co luu hay chua
        public static bool CheckVip_Exits(int newshouseID)
        {
            try
            {
                int count = 0;
                using (var mgr = ContextManager<HousingInfoDataContext>
                        .GetManager(Database.HousingInfoConnection))
                {
                    count = mgr.DataContext.NewsSaves.Count(n => n.NewsHouseID == newshouseID);
                }
                if (count > 0)
                    return true;
                else return false;
            }
            catch
            {
                return true;
            }
        }
        #endregion
	}
}
